# -*- coding: utf-8 -*-
#here be houses

import pyglet
import random

from objects import *
import music

batch = pyglet.graphics.Batch()

bilter = [pyglet.resource.image("td-" + str(n) + ".png") for n in xrange(1,6)]

class House(GameObject):
    def __init__(self, x, y, image):
        #quickfix:
        image.anchor_x = image.width/2
        image.anchor_y = image.height/2
        self.sprite = pyglet.sprite.Sprite(image, x, y, batch=batch)
        super(House, self).__init__()

    def be_hit(self, damage):
        self.hitpoints -= damage
        if self.hitpoints <= 0:
            World.buildings.remove(self)
            self.sprite.delete()
        music.play_sfx("explosion")

class HouseA(House):
    def __init__(self, x, y):
        img = random.choice(bilter)
        House.__init__(self, x, y, img)

        #special variables
        self.hitpoints = 600 + random.randint(-200,200)

house_types = {"A": HouseA,
               }